/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/12/03
*/
#include "LuaTableLayout.h"
#include "../../utilities/Log.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

#define CObjPtr (TableLayout::ToTableLayout(m_cobj))

void* LuaTableLayout::GetInterface(void* data)
{
    if (!data) return 0;
    LuaTableLayout* tableLayout = new LuaTableLayout((TableLayout*)data);
#ifdef EDUI_TEST_NEW_DELETE
    ++m_newdeleteNum;
    Log("[LuaTableLayout] new LuaTableLayout : %d, %d", tableLayout, data);
#endif
    return tableLayout;
}

void LuaTableLayout::Release()
{
#ifdef EDUI_TEST_NEW_DELETE
    --m_newdeleteNum;
    Log("[LuaTableLayout] delete LuaTableLayout : %d, %d, %s", this, m_cobj, this->GetName());
#endif
    delete this;
}

LuaTableLayout::LuaTableLayout(TableLayout* tableLayout) : LuaContainer(tableLayout)
{}

LuaTableLayout::~LuaTableLayout()
{}

//----------------------------------------//

size_t LuaTableLayout::GetSelected()
{
    return CObjPtr->GetSelected();
}

bool LuaTableLayout::SetSelected(size_t iSelected)
{
    return CObjPtr->SetSelected(iSelected);
}

//----------------------------------------//

void LuaTableLayout::Register(LuaState *L)
{
    LuaObject obj = LuaHelperNS::AddToMetas(L, "TableLayout", "Container");
    obj.SetObject("__index", obj);
    obj.RegisterDirect("__NewCObj__", &LuaTableLayout::GetInterface);

    
    obj.RegisterObjectDirect("GetSelected", (LuaTableLayout*)0, &LuaTableLayout::GetSelected);
    obj.RegisterObjectDirect("SetSelected", (LuaTableLayout*)0, &LuaTableLayout::SetSelected);
}

#undef CObjPtr

EDUI_NAMESPACE_END

#endif